package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type Appcongfig struct {
	Mysql
	Redis
}
type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}
type Redis struct {
	Password string
	Host     string
	Port     int
	Database int
}

var Appconf Appcongfig

func Init() {
	viper.SetConfigFile("../appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("动态配置链接失败了")
	} else {
		fmt.Println("动态配置连接成功")
	}
	viper.Unmarshal(&Appconf)
}
